<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style/css/main.css" rel="stylesheet" type="text/css" />
<script src="style/js/jquery.js" type="text/javascript"></script>
<script src="style/js/main.js" type="text/javascript"></script>
<title>系统信息</title>
</head>

<body>
<div class="main">
<?php
if(!isset($_GET['action']))
{
?>
	<table id="main_table">
    	<tr>
        	<th colspan="9" align="left"><?php echo $title;?></th>
        </tr>
        
        <tr>
        	<td align="center" width="30%">类目</td>
        	<td align="center" width="40%">描述</td>
        	<td align="center" width="30%">操作</td>
        </tr>
        <?php
        if(!empty($class))
        {
        	foreach($class as $v)
        	{
        ?>
        <tr>
        	<td align="left"><a href="books_class.php?action=edit&id=<?php echo $v['id'];?>"><?php echo $v['value'] . '【ID' . $v['id'] . '】';?></a></td>
        	<td align="left" class="indent"><?php echo $v['description'];?></td>
        	<td align="center">
            <a href="books_class.php?action=add&fid=<?php echo $v['fid'];?>" class="add_img">[增加子类]</a>
            <a href="books_class.php?action=edit&id=<?php echo $v['id'];?>" class="edit_img">[编辑]</a>
            <a href="books_class.php?action=del&id=<?php echo $v['id'];?>&fid=<?php echo $v['fid'];?>" onclick="return confirm('你确定要删除？')" class="del_img">[删除]</a>
            </td>
        </tr>
        <?php
        	}
        }
        else
        {
        ?>
        <td align="center" colspan="3">暂无分类</td>
        <?php
        }
        ?>
        <tr>
        	<td align="center" colspan="3">
            <input class="btn2" type="button" value="增加顶级分类" onclick="location.href='books_class.php?action=add&fid=0'" />
            </td>
        </tr>
    </table>
<?php
}
else if(isset($_GET['action']))
{
?>
<table>
<form action="books_class.php" method="post">
<?php
if($_GET['action'] == 'add')
{
?>
<input type="hidden" name="fid" value="<?php echo $_GET['fid'];?>" />
<?php
}else if($_GET['action'] == 'edit')
{
?>
<input type="hidden" name="id" value="<?php echo $_GET['id'];?>" />
<?php
}
?>
    	<tr>
        	<th colspan="2" align="left"><?php echo $title;?></th>
        </tr>
        <tr>
        	<td align="left" class="indent">分类名称：</td>
        	<td align="left" class="indent"><input type="text" name="value" class="midtext"
           value="<?php if(isset($edit)) echo $edit['value'];?>" /></td>
        </tr>
        <tr>
        	<td align="left" class="indent">描述：</td>
        	<td align="left" class="indent"><textarea name="description" cols="50" rows="6"><?php if(isset($edit)) echo $edit['description'];?></textarea></td>
        </tr>
        <tr>
        	<td align="left" class="indent">是否在主页显示：</td>
        	<td align="left" class="indent">
            <select name="show">
            <option value="0" <?php if(isset($edit)) echo $edit['show'] == 0 ? 'selected="selected"' : '';?>>不显示</option>
            <option value="2" <?php if(isset($edit)) echo $edit['show'] == 2 ? 'selected="selected"' : '';?>>图书分类</option>
            <option value="1" <?php if(isset($edit)) echo $edit['show'] == 1 ? 'selected="selected"' : '';?>>导航栏</option></select></td>
        </tr>
       	<tr>
        	<td align="center" colspan="2">
            <input type="hidden" name="<?php if(isset($edit)){ echo 'edit';}else{echo 'sub';}?>" value="1" />
            <input type="submit" id="cadd_sub" class="btn" value="<?php if($_GET['action'] == 'edit'){echo '更改';}else{echo '添加';}?>" />
            <input type="reset" class="btn" value="重写" /> 
            <input type="buttin" class="btn" value="返回" onclick="history.go(-1)" />
            </td>
        </tr>
</form>
</table>
<?php
}
?>
</div>
<?php echo $copyright;?>
</body>
</html>
